#pragma once
#include"RBtree.h"
namespace mutou
{
	template<class K>
	class set
	{
		struct setofT;
		typedef RBTree<K, const K, setofT> RBtree;
	public:
		typedef typename RBTree<K, const K, setofT>::Iterator iterator;
		typedef typename RBTree<K, const K, setofT>::ConstIterator const_iterator;
		iterator begin()
		{
			return t.Begin();
		}
		iterator end()
		{
			return t.End();
		}
		const_iterator begin() const
		{
			return t.Begin();
		}
		const_iterator end() const 
		{
			return t.End();
		}
		pair<iterator,bool> insert(const K& val)
		{
			return t.insert(val);
		}
	private:
		struct setofT
		{
			const K& operator()(const K& val)
			{
				return val;
			}
		};
		RBtree t;
		
	};
	template <class T>
	void print(set<T> st)
	{
		typename set<T>::iterator it = st.begin();
		while (it != st.end())
		{
			cout << *it << " ";
				++it;
		}
		cout << endl;
	}
	void print( const set<int>st)
	{
		set<int>::const_iterator it = st.end();
		while (it != st.begin())
		{
			--it;
			
			cout << *it << " ";
		

		}
		cout << endl;
	}

	void test02()
	{
		set<int> st;
		st.insert(1);
		st.insert(2);
		st.insert(8888);
		st.insert(4);
		st.insert(4222);
		st.insert(42);
		st.insert(43);
		print(st);
	}
}
